package cn.dkk.behavior_design.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @author dkk
 * @date 2022/7/31
 * @desc
 */
public class StudentAggregateImpl implements StudentAggregate{

    private List<Student> studentList = new ArrayList<>();

    @Override
    public boolean add(Student student) {
        return studentList.add(student);
    }

    @Override
    public boolean remove(Student student) {
        return studentList.remove(student);
    }

    @Override
    public StudentIterator iterator() {
        StudentIteratorImpl studentIterator = new StudentIteratorImpl();
        studentIterator.setStudentList(studentList);
        return studentIterator;
    }
}
